package com.lanxiao.cloud.modules.log.controller;

import com.lanxiao.cloud.common.core.dto.PageQuery;
import com.lanxiao.cloud.common.core.dto.ResultModel;
import com.lanxiao.cloud.modules.log.application.LogQueryManager;
import com.lanxiao.cloud.modules.log.application.dto.LogDto;
import com.lanxiao.cloud.modules.log.application.dto.LogQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.web.PageableDefault;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：qiaoliang
 * @date ：2021-10-15
 */
@Api(tags = "日志")
@Validated
@RequestMapping("/logs")
@RestController
public class LogController {

  private final LogQueryManager logQueryManager;

  public LogController(LogQueryManager logQueryManager) {
    this.logQueryManager = logQueryManager;
  }

  @ApiOperation(value = "条件查询操作日志列表")
  @GetMapping("/operation")
  public ResultModel<LogDto> operationPage(LogQuery query, PageQuery page) {
    return logQueryManager.page(false, query, page);
  }

  @ApiOperation(value = "条件查询登录日志列表")
  @GetMapping("/on-line")
  public ResultModel<LogDto> onLinePage(LogQuery query, PageQuery page) {
    return logQueryManager.page(true, query, page);
  }

}
